package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;

import com.zzyl.dto.NursingProjectDto;

import com.zzyl.service.NursingProjectService;
import com.zzyl.vo.ContractVo;
import com.zzyl.vo.NursingProjectVo;
import com.zzyl.vo.RoomVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursing_project")
@Api(tags = "护理管理")
public class NursingProjectController extends BaseController {


    @Autowired
    private NursingProjectService nursingProjectService;

    /**
     * 分页查询护理项目信息
     *
     * @return 分页结果
     */
    @GetMapping
    @ApiOperation(value = "分页查询护理信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "项目名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query"),
    })
    public ResponseResult<PageResponse<ContractVo>> selectByPage(Integer pageNum,
                                                                 Integer pageSize,
                                                                 String name,
                                                                 Integer status) {
        PageResponse<NursingProjectVo> pageInfo = nursingProjectService.selectByPage(pageNum, pageSize, name, status);
        return success(pageInfo);
    }


    @PostMapping
    @ApiOperation(value = "添加护理项目", notes = "传入护理项目信息，返回添加结果")
    public ResponseResult addNursingProject(@RequestBody NursingProjectDto nursingProjectDto) {
        nursingProjectService.addNursingProject(nursingProjectDto);
        return success();
    }

    @GetMapping("/{id}")
    @ApiOperation("回显护理项目信息")
    public ResponseResult<RoomVo> getNursingProject(@PathVariable Long id) {
        NursingProjectVo vo = nursingProjectService.getNursingProject(id);
        return success(vo);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改护理项目信息")
    public ResponseResult updateNursingProject(@RequestBody NursingProjectDto nursingProjectDto, @PathVariable Long id) {
        nursingProjectService.updateNursingProject(nursingProjectDto);
        return success();
    }



    @DeleteMapping("/{id}")
    @ApiOperation("删除对应护理项目信息")
    public ResponseResult deleteNursingProject( @PathVariable Long id) {
        nursingProjectService.deleteNursingProject(id);
        return success();
    }


    @PutMapping("/{id}/status/{status}")
    @ApiOperation("修改护理项目状态")
    public ResponseResult updateStatus(@PathVariable Long id, @PathVariable Integer status) {
        nursingProjectService.updateStatus(id, status);
        return success();
    }
}
